package cn.itcast.mq.listener;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/*
 *TODO
 *@Author Mister
 *@Date 2025/1/5 10:54
 */
@Component
public class SpringRabbitListener {
    @RabbitListener(queues ="simple.queue")
    public void workQueue1(String msg){

        System.out.println("simple.queue接收到消息："+msg);
    }
    @RabbitListener(queues ="work.queue")
    public void workQueue2(String msg) throws InterruptedException {
        System.out.println("work.queue222接收到消息："+msg);
        TimeUnit.MILLISECONDS.sleep(10);

    }
    @RabbitListener(queues ="work.queue")
    public void simpleListener(String msg) throws InterruptedException {
        System.out.println("work.queue111接收到消息："+msg);
        TimeUnit.MILLISECONDS.sleep(100);
    }

    @RabbitListener(queues ="fanout.queue1")
    public void fanoutListener1(String msg)  {
        System.out.println("fanout.queue1接收到消息："+msg);

    }
    @RabbitListener(queues ="fanout.queue2")
    public void fanoutListener2(String msg)  {
        System.out.println("fanout.queue2接收到消息："+msg);

    }
}

